package org.cuieney.videolife.presenter;

import org.cuieney.videolife.common.api.ShortVideoApiService;
import org.cuieney.videolife.common.api.WyApiService;
import org.cuieney.videolife.common.base.RxPresenter;
import org.cuieney.videolife.common.utils.RxUtil;
import org.cuieney.videolife.presenter.contract.ShortVideoHomeContract;

import javax.inject.Inject;

import rx.Subscription;

/**
 * Created by cuieney on 17/3/4.
 */

public class ShortVideoHomePresenter extends RxPresenter<ShortVideoHomeContract.View> implements ShortVideoHomeContract.Presenter {
    private ShortVideoApiService mRetrofitHelper;

    @Inject
    public ShortVideoHomePresenter(ShortVideoApiService mRetrofitHelper) {
        this.mRetrofitHelper = mRetrofitHelper;
    }

    @Override
    public void getVideoData(String as, String cp, int ts) {
        Subscription rxSubscription = mRetrofitHelper.getVideoData(as, cp, "" + ts)
                .compose(RxUtil.rxSchedulerHelper())
                .subscribe(douyinVideoListData -> {
                    mView.showContent(douyinVideoListData);
                }, throwable -> {
                    mView.error(throwable);
                });
        addSubscrebe(rxSubscription);
    }
}
